package com.jt.tenant.popwindow;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import com.bigkoo.pickerview.lib.ArrayWheelAdapter;
import com.bigkoo.pickerview.lib.OnWheelChangedListener;
import com.bigkoo.pickerview.lib.ScreenInfo;
import com.bigkoo.pickerview.lib.WheelView;
import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/4/28.
 */
public class PicShowPopup extends PopupWindow implements View.OnClickListener{

    private View rootView; // 总的布局

    private LinearLayout all;

    private ImageView imageView;

    private String type;

    public PicShowPopup(Context context) {

        super(context);

        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);

        this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);

        this.setBackgroundDrawable(new BitmapDrawable());// 这样设置才能点击屏幕外dismiss窗口

        this.setOutsideTouchable(true);

        this.setAnimationStyle(com.bigkoo.pickerview.R.style.timepopwindow_anim_style);

        LayoutInflater mLayoutInflater = LayoutInflater.from(context);

        rootView = JTApplication.ScaleScreenHelper.loadView((ViewGroup) mLayoutInflater.inflate(R.layout.popup_pic_show, null));

        imageView = (ImageView) rootView.findViewById(R.id.iv_pic_show);

        (all = (LinearLayout)rootView.findViewById(R.id.lin_pic_show)).setOnClickListener(this);

        setContentView(rootView);

    }



    public void show(){

        if(type.equals("0")){

            imageView.setImageResource(R.mipmap.img_vin);

        }else {

            imageView.setImageResource(R.mipmap.img_engine);

        }

        showAtLocation(rootView, Gravity.TOP, 0, 40);

    }

    public void setType(int type){

        this.type = String.valueOf(type);

    }


    @Override
    public void onClick(View v) {

        switch (v.getId()){

            case R.id.lin_pic_show:

                dismiss();

                break;

        }

    }
}